def options(opt):
	opt.load('compiler_c')

def configure(conf):
	conf.load('compiler_c')
	conf.env.append_unique('CFLAGS', ['-Wall', '-g', '-fPIC'])
	conf.recurse('file')

def build(bld):
	bld.shlib(source='''op.c sign.c base64.c conn.c dbg.c data.c exml.c
			    util.c''',
		  target='elasto_core',
		  vnum='0.0.3',
		  lib=['crypto', 'expat', 'ssl',
		       ':libevent-2.1.so.5', ':libevent_openssl-2.1.so.5'],
		  use=['ccan'],
		  includes = '. ..',
		  defines = ['_GNU_SOURCE'])
	bld.stlib(source='s3_creds.c s3_req.c s3_path.c',
		  target='elasto_req_s3',
		  lib=['crypto', 'expat', 'ssl',
		       ':libevent-2.1.so.5', ':libevent_openssl-2.1.so.5'],
		  use=['elasto_core'],
		  includes = '. ..',
		  defines = ['_GNU_SOURCE'])
	bld.shlib(source='''azure_ssl.c azure_req.c azure_mgmt_req.c''',
		  target='elasto_req_azure_core',
		  lib=['crypto', 'expat', 'ssl',
		       ':libevent-2.1.so.5', ':libevent_openssl-2.1.so.5'],
		  use=['elasto_core'],
		  includes = '. ..',
		  defines = ['_GNU_SOURCE'])
	bld.stlib(source='''azure_fs_req.c''',
		  target='elasto_req_azure_fs',
		  lib=['crypto', 'expat', 'ssl',
		       ':libevent-2.1.so.5', ':libevent_openssl-2.1.so.5'],
		  use=['elasto_req_azure_core'],
		  includes = '. ..',
		  defines = ['_GNU_SOURCE'])
	bld.stlib(source='''azure_blob_req.c''',
		  target='elasto_req_azure_blob',
		  lib=['crypto', 'expat', 'ssl',
		       ':libevent-2.1.so.5', ':libevent_openssl-2.1.so.5'],
		  use=['elasto_req_azure_core'],
		  includes = '. ..',
		  defines = ['_GNU_SOURCE'])
	bld.install_as('${INCLUDEDIR}/elasto/data.h', 'data_api.h')
	bld.recurse('file')
